<%@page import="kau.dao.CustomerDAOImpl"%>
<%@page import="org.springframework.web.context.request.SessionScope"%>
<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>

<%@	page import="kau.dao.*"%>
<%@	page import="kau.vo.*"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>

<title>기본정보수정</title>
<script>
	function check_mail(frm) {

		if (frm.email_list.value != "" && frm.email_list.value != "self") {
			frm.mailDomain.value = frm.email_list.value;
			frm.mailDomain.readOnly = true;
		} else if (frm.email_list.value == "self") {
			frm.mailDomain.value = '';
			frm.mailDomain.readOnly = false;
			frm.mailDomain.focus();
		} else if (frm.email_list.value == "") {
			frm.mailDomain.value = '';
			frm.mailDomain.readOnly = true;
		}
	}
		function check_question(frm){
		if (frm.question_list.value != "" && frm.question_list.value != "self") {
			frm.passwordQuestion.value = frm.question_list.value;
			frm.passwordQuestion.readOnly = true;
		} else if (frm.question_list.value == "self") {
			frm.passwordQuestion.value = '';
			frm.passwordQuestion.readOnly = false;
			frm.passwordQuestion.focus();
		} else if (frm.question_list.value == "") {
			frm.passwordQuestion.value = '';
			frm.passwordQuestion.readOnly = true;
		}
		
	}
	function checkForm() {
		var mailAccount = document.getElementById("mailAccount").value;
		var phoneNumber1 = document.getElementById("phoneNumber1").value;
		var phoneNumber2 = document.getElementById("phoneNumber2").value;
		var phoneNumber3 = document.getElementById("phoneNumber3").value;
		
		var passwordAnswer = document.getElementById("passwordAnswer").value;
		
		if(mailAccount == null|| mailAccount ==""){
			alert("메일주소를 입력하세요");
			document.getElementById("mailAccount").focus();
			return false;
		} else if(phoneNumber1.length!=3){
			alert("핸드폰번호를 확인하세요");
			document.getElementById("phoneNumber1").focus();
			return false;
		} else if(phoneNumber2.length < 3 || phoneNumber2.length > 4){
			alert("핸드폰번호를 확인하세요");
			document.getElementById("phoneNumber2").focus();
			return false;
		} else if(phoneNumber3.length!=4){
			alert("핸드폰번호를 확인하세요");
			document.getElementById("phoneNumber3").focus();
			return false;
		} else if(passwordAnswer == null || passwordAnswer==""){
			alert("질문에 대한 답을 입력하세요");
			document.getElementById("passwordAnswer").focus();
			return false;
		}
		else{
			alert("회원정보가 수정되었습니다.");
			return true;
		}
			
	}

</script>
<style type="text/css">
#info {
	font-family: '맑은고딕', dotum, sans-serif, bold;
	font-size: 13px
}
</style>

<style type="text/css">
<!--
@import url("/nems/css/style.css");
-->
</style>
</head>
<body>

	<%
		String custId = (String) session.getAttribute("custId");
		Customer customer = CustomerDAOImpl.getInstance().getCustomer(
				custId);
	%>
	<div style="margin-left: 20px" id="info">
		<form class="form-inline" name="update_fm" method="post"
			action="update_cust.cust" >
			<input type="hidden" name="custId" value="<%=custId%>" />
			<table>
				<tr>

					<td><img src="/nems/cust/img/myPageImg.png" width="60"
						height="50" alt="기본정보 수정" /></td>
					<td><h3>
							<strong>기본정보수정</strong>
						</h3></td>

				</tr>
			</table>
			<br> <br>


			<div class="id_pw">
				<hr>
				<table width="600" border="0">
					<tr align="left">
						<td width="300" height="40">아이디</td>
						<td width="300">${sessionScope.custId}</td>
					</tr>

					<tr align="left">
						<td width="300" height="40">이름</td>
						<td width="300"><input type="text" id="custName" disabled="disabled"
							name="custName" value=<%=customer.getCustName()%> /></td>
					</tr>

					<tr align="left">
					<td width="300" height="40">주민등록번호</td>
						<td width="300"><input type="text" name="jumin1" id="jumin1" disabled="disabled"
							size="6" maxlength="6" onKeyPress="num_only()" value=<%=customer.getPreCustSsn()%> >-<input
							type="text" name="jumin2" id="jumin2" disabled="disabled" size="7" maxlength="7"
							onKeyPress="num_only()" value=<%=customer.getPostCustSsn()%>></td>
					</tr>

					<tr align="left">
						<td width="300" height="40">Email</td>
						
						<td width="300">
						
						
						<input type="text" size="10" value="<%=customer.getCustEmailAccount() %>" name="mailAccount" id="mailAccount"
							title="이메일 아이디 입력" />
						
						@ <input type="text"  size="10" value="<%=customer.getCustEmailDomain() %>" name="mailDomain"
							title="이메일 도메인 입력" readonly="readonly"/> 
							
							<select name="email_list" id="email_list" onchange="check_mail(this.form);" >
							<option value="<%=customer.getCustEmailDomain() %>" selected='selected'>선택해 주세요.</option>
							<option value="naver.com">naver.com</option>
							<option value="chol.com">chol.com</option>
							<option value="dreamwiz.com">dreamwiz.com</option>
							<option value="empal.com">empal.com</option>
							<option value="freechal.com">freechal.com</option>
							<option value="gmail.com">gmail.com</option>
							<option value="hanafos.com">hanafos.com</option>
							<option value="hanmail.net">hanmail.net</option>
							<option value="hanmir.com">hanmir.com</option>
							<option value="hitel.net">hitel.net</option>
							<option value="hotmail.com">hotmail.com</option>
							<option value="korea.com">korea.com</option>
							<option value="lycos.co.kr">lycos.co.kr</option>
							<option value="nate.com">nate.com</option>
							<option value="netian.com">netian.com</option>
							<option value="paran.com">paran.com</option>
							<option value="yahoo.com">yahoo.com</option>
							<option value="yahoo.co.kr">yahoo.co.kr</option>
							<option value="self">직접입력</option>
						</select>

					</tr>

					<tr align="left">
						<td width="300" height="40">핸드폰번호</td>
						<td width="300"><input type="text" name="phoneNumber1"
							id="phoneNumber1" size="3" maxlength="3" onKeyPress="num_only()" value=<%=customer.getPhoneNumber1()%> />
							- <input type="text" id="phoneNumber2" name="phoneNumber2"
							size="4" maxlength="4" onKeyPress="num_only()" value=<%=customer.getPhoneNumber2()%> /> - <input
							type="text" name="phoneNumber3" id="phoneNumber3" size="4"
							maxlength="4" onKeyPress="num_only()"
							value=<%=customer.getPhoneNumber3()%> /></td>
					</tr>

					<tr align="left">
						<td width="300" height="40">부모님 핸드폰번호</td>
						<td width="300"><input type="text" name="parentPhoneNumber1"
							id="parentPhoneNumber1" size="3" maxlength="3"
							onKeyPress="num_only()"  disabled="disabled"  
							value=<%=customer.getParentPhoneNumber1()%> /> - <input type="text"  disabled="disabled" id="parentPhoneNumber2" name="parentPhoneNumber2" size="4"
							maxlength="4" onKeyPress="num_only()" value=<%=customer.getParentPhoneNumber2()%> /> - <input type="text"
							name="parentPhoneNumber3" id="parentPhoneNumber3"  disabled="disabled"  size="4"
							maxlength="4" onKeyPress="num_only()"
							value=<%=customer.getParentPhoneNumber3()%> /></td>
					</tr>

					<tr align="left">
						<td width="300" height="40">비밀번호 찾기 질문</td>
					<td width="300">
						<input type="text" size="30" value="<%=customer.getPasswordQuestion()%>" name="passwordQuestion"
							title="비밀번호찾기질문" /> 
						<select id="question_list"
							name="question_list" onchange="check_question(this.form);" >
								<option value="<%=customer.getPasswordQuestion()%>">선택하세요</option>
								<option value="본인의 출생지는?">본인의 출생지는?</option>
								<option value="나의 출신 초등학교는?">나의 출신 초등학교는?</option>
								<option value="나의 좌우명은?">나의 좌우명은?</option>
								<option value="가장 생각나는 친구 이름은?">가장 생각나는 친구 이름은?</option>
								<option value="나의 보물 제1호는?">나의 보물 제1호는?</option>
						</select></td>
					</tr>
					<tr align="left">

						<td width="300" height="40">비밀번호 찾기 답</td>
						<td width="300"><input type="text" id="passwordAnswer"
							name="passwordAnswer" value=<%=customer.getPasswordAnswer()%> /></td>
					</tr>

				</table>
			</div>
			<hr>
			
				<br>

			<button class="positive" style="width: 70px" type="submit"
				onclick="return checkForm()">
				<img src="cust/img/shopping_cart_accept.png"
					style="width: 20px; height: 10px" />확인
			</button>
			
			<button class="negative" style="width: 70px"
				onclick="javascript:history.go(-1)">
				<img src="cust/img/shopping_cart_accept.png"
					style="width: 20px; height: 10px" />취소
			</button>
		</form>


	</div>
</body>
</html>